package creator.prototype;

import creator.prototype.deep.DeepGunner;
import creator.prototype.deep.DeepNumerical;
import creator.prototype.deep.DeepSpecialvalue;
import creator.prototype.light.Gunner;
import creator.prototype.light.Numerical;
import creator.prototype.light.Specialvalue;

public class Demo {

    public static void main(String[] args)  throws Exception{
        // 浅克隆测试
        Gunner gunner2 = getGunner();
        System.out.println("生产长枪兵: "+gunner2.toString());
        gunner2.setNumerical(null);
        System.out.println("gunner:" + gunner2);
        Gunner gunner3 = getGunner();
        System.out.println("生产长枪兵2:"+ gunner3.toString());
        System.out.println("gunner2:" + gunner3);
        // 深克隆测试
        DeepGunner gunner4 = getDeepGunner();
        System.out.println("生产长枪兵3：" + gunner4.toString());
    }

    private static Gunner getGunner() throws Exception{
        // 浅复制
        Gunner gunner = new Gunner();
        gunner.setIntroduce("长枪兵 对骑兵攻击力 + 3 对步兵攻击力 -1 对弓箭手防御力 - 2");
        gunner.setIndexNo("01");
        gunner.setNumerical(new Numerical("普通长枪兵","3","1","6",new Specialvalue("火","1000")));
        return  (Gunner) gunner.clone();
    }

    private static DeepGunner getDeepGunner(){
        // 浅复制
        DeepGunner gunner = new DeepGunner();
        gunner.setIntroduce("长枪兵 对骑兵攻击力 + 3 对步兵攻击力 -1 对弓箭手防御力 - 2");
        gunner.setIndexNo("01");
        gunner.setNumerical(new DeepNumerical("普通长枪兵","3","1","6",new DeepSpecialvalue("火","1000")));
        return (DeepGunner)gunner.deepClone();
    }
}
